/*
 * @Descripttion: 
 * @version: 
 * @Author: fmy1993
 * @Date: 2021-07-23 16:57:15
 * @LastEditors: fmy1993
 * @LastEditTime: 2021-08-13 19:51:26
 */

import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../components/Main.vue'
import Login from '../components/Login.vue'
import Register from '../components/Register.vue'
import Form from '../components/Form.vue'
import Home from '../components/Home.vue'
import BigData from '../components/BigData.vue'
import Table from '../components/tableComponent.vue'
import * as echarts from 'echarts'
import form1 from '../components/form1.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/main' },
  { path:'/main',component:Main},
  { path:'/login',component:Login},
  {path:'/register',component:Register},
  {path:'/form',component:Form},
  { path: '/home', component: Home },
  {path:'/bigdata',component:BigData},
  {path:'/table',component:Table},//测试组件
  {path:'/form1',component:form1},//测试组件
]

const router = new VueRouter({
  routes
})
// 有这个守卫的话函数会请求会直接进函数里，就什么也不显示
// router.beforeEach((to,from,next)=>{
//   //to 将要访问的路径
//   //from 代表从哪个路径跳转而来
//   //next 是一个函数，表示放行
//   // next() 放行   next('/login') 强制跳转
//   if(to.path === '/login') return next();
//   //获取 token
//   const tokenStr = window.sessionStorage.getItem('token');
//   if(!tokenStr) return next('/login');
//   next();
// })

export default router
